package com.xiyu.service.convert.mailbox;

import com.xiyu.service.model.mailbox.mail.MailboxMailApprove;
import com.xiyu.service.vo.mailbox.mail.MailSaveMailInput;
import com.xiyu.service.vo.mailbox.mail.MailReceiverMultiQueryOutput;
import com.xiyu.service.model.mailbox.label.MailboxLabel;
import com.xiyu.service.vo.mailbox.mail.MailGetMailDetailOutput;
import com.xiyu.service.model.mailbox.mail.MailboxMail;
import com.xiyu.service.vo.mailbox.mail.MailPageMailOutput;
import com.xiyu.service.vo.mailbox.mail.MailSingleGetLabelOutput;
import com.xiyu.service.vo.mailbox.mail.MailListLabelOutput;
import com.xiyu.service.vo.mailbox.mail.MailGetFolderByAccountIdsOutput;
import com.xiyu.service.model.mailbox.folder.MailboxFolder;
import org.babyfish.jimmer.sql.ast.tuple.Tuple4;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 邮件管理 Convert
 */
@Mapper
public interface MailConvert {
    MailConvert INSTANCE = Mappers.getMapper(MailConvert.class);

    List<MailGetFolderByAccountIdsOutput> getFolderByAccountIdsOutputConvert(List<MailboxFolder> output);

    List<MailListLabelOutput> listLabelOutputConvert(List<MailboxLabel> output);

    MailSingleGetLabelOutput singleGetLabelOutputConvert(MailboxLabel output);

    @Mapping(source = "mail", target = ".")
    @Mapping(source = "status", target = "approveStatus")
    @Mapping(source = "id", target = "approveId")
    MailPageMailOutput pageMailApproveOutPutConvert(MailboxMailApprove output);

    List<MailPageMailOutput> pageMailApproveOutPutConvert(List<MailboxMailApprove> output);

    List<MailPageMailOutput> pageMailOutPutConvert(List<MailboxMail> output);

    MailGetMailDetailOutput getMailDetailOutputConvert(MailboxMail output);


    List<MailReceiverMultiQueryOutput> receiverQueryOutputConvert(List<Tuple4<String, String, Long, Integer>> output);

    @Mapping(source = "_1", target = "name")
    @Mapping(source = "_2", target = "address")
    @Mapping(source = "_3", target = "id")
    @Mapping(source = "_4", target = "type")
    MailReceiverMultiQueryOutput receiverQueryOutputConvert(Tuple4<String, String, Long, Integer> output);

    MailboxMail saveMailInputConvert(MailSaveMailInput input);

    List<MailPageMailOutput> pageMailOutputConvert(List<MailboxMail> output);

}
